import Cookies from 'js-cookie'
import Config from '@/settings'

const TokenKey = Config.TokenKey

export function getToken() {
  return Cookies.get(TokenKey)
}
export function getUser() {
	let lsit ={
		id:0,
		nickName:null
	}
    return !Cookies.get("User")?lsit:JSON.parse(Cookies.get("User"))
}
export function setToken(token,user, rememberMe) {
	Cookies.set("User", JSON.stringify(user))
  if (rememberMe) {
	  Cookies.set("User", JSON.stringify(user), { expires: Config.tokenCookieExpires })
    return Cookies.set(TokenKey, token, { expires: Config.tokenCookieExpires })
  } else return Cookies.set(TokenKey, token)
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}
